import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/14 16:07
 * @description
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int year = in.nextInt(), month = in.nextInt(), day = in.nextInt();
            int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
            if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
                // 闰年
                days[1] = 29;
            }
            int ans = 0;
            for (int i = 0; i < month - 1; i++) {
                ans += days[i];
            }
            ans += day;
            System.out.println(ans);
        }
    }
}
